import numpy as np
import pandas as pd
import statsmodels.api as sm
import math
import sys


### Operational audits and predicted race probabilitiess
dataBISG = pd.read_csv("/REDACTED/data/final/individualBISG2014_full_final.csv")
dataBISG= dataBISG[~dataBISG.predicted_prob_black.isna()]

##########################################################
#### TABLE A1
##########################################################
sys.stdout = open("/REDACTED/aud_freq_time_type.txt", "w")

aud_data = dataBISG[dataBISG.aud_no_research_audits==1]
eitc_pop = aud_data[aud_data.isEIC==1]
#act_270_pop = aud_data[aud_data.total_pos_inc_class==70]
#act_271_pop = aud_data[aud_data.total_pos_inc_class==71]

print("EITC returns \n")

print(pd.crosstab(eitc_pop.post_ref, eitc_pop.non_corr_aud, margins = True))

print(pd.crosstab(eitc_pop.post_ref, eitc_pop.non_corr_aud, margins = True, normalize = 'all'))

#print("\n\nEITC 270 returns \n")

#print(pd.crosstab(act_270_pop.post_ref, act_270_pop.non_corr_aud, margins = True))

#print(pd.crosstab(act_270_pop.post_ref, act_270_pop.non_corr_aud, margins = True, normalize = 'all'))


#print("\n\nEITC 271 returns \n")

#print(pd.crosstab(act_271_pop.post_ref, act_271_pop.non_corr_aud, margins = True))

#print(pd.crosstab(act_271_pop.post_ref, act_271_pop.non_corr_aud, margins = True, normalize = 'all'))

sys.stdout = sys.__stdout__